package com.zxh.servlets;
/*
重定向和转发的区别
1.重定向：地址发生了改变，转发：不发生改变
2.重定向是客户端行为 转发是服务器行为
3.重定向可以访问其他服务器资源  转发只能访问自己服务器资源 



 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/login")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       /* //跳转
        //假设设置/login的时候自动跳转到login.html网页
        //使用http协议 302 location：跳转地址
        response.setStatus(302);
        response.setHeader("location",request.getContextPath()+"/login.html");
*/
        //简单的跳转方法(重定向)
        response.sendRedirect(request.getContextPath()+"/login.html");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);

    }
}
